xend: Prevent XenD touching externally managed bridges
authorKeir Fraser <keir.fraser@citrix.com>
Sat, 15 Dec 2007 18:26:52 +0000 (18:26 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Sat, 15 Dec 2007 18:26:52 +0000 (18:26 +0000)
commit9d379685d65edb8e1c75617eca50687d52c5f6f3
tree38cfaff458f8a10f5b2e80982488353f39f3b998
parent8710cb7a9156d0648d54700669adb9d79529dfb6
xend: Prevent XenD touching externally managed bridges

With current XenD 3.0.4 or later try the following:

    brctl addbr demo
    ifconfig demo up

    /etc/init.d/xend start
    /etc/init.d/xend stop

    ifconfig demo down
    brctl delbr demo

Now, start XenD again....

    /etc/init.d/xend start

And watch in horror as it re-creates your 'demo' bridge.

The problem is that the 'XendNetwork' class does not distinguish
between bridge devices that it is managing (ie those created via
XenAPI) and those which it does not manage (ie those created by OS
distro init scripts, or by apps like  libvirt).

While initially I thought I could just make XenD ignore
externally-managed bridges completely, it seems to needs to know about
them otherwise it can't hook up guest VIFs to them correctly. So the
attached patch adds a 'managed' flag to the XendNetwork
class. Externally managed bridges have this set to False. At startup
XenD will now only re-create bridge devices which have the 'managed'
flag set to 'True'  - ie those created via XenAPI.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
tools/python/xen/xend/XendNetwork.py